﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DelonixRegiaHMSys.Core.Interfaces;
using DelonixRegiaHMSys.Core.Models;

namespace DelonixRegiaHMSys.Infrastructure.Data
{
    public class EfRoomStatusReportQuery : IRoomStatusReportQuery
    {
        public IEnumerable<RoomStatusReport> GetAllRoomStatusReport()
        {
            var context = new hmsDBEntities();
            return context.roomDetails.Select(rsr => new RoomStatusReport()
            {
                roomNum = rsr.roomNum,
                roomType = rsr.roomType,
                floorLevel = rsr.floorLevel,
                bedType = rsr.bedType, 
                smokingOrNot = rsr.smokingOrNot,
                maxOccupancy = rsr.maxOccupancy, 
                roomStatus = rsr.roomStatus,
                roomRates = rsr.roomRates
            });
        }

        public RoomStatusReport RetrieveRoomStatusReportByRoomNum(int roomNum)
        {
            var context = new hmsDBEntities();
            RoomStatusReport b = new RoomStatusReport();
            var retrieveRoomStatusReportByRoomNum = context.roomDetails.FirstOrDefault(rsr => rsr.roomNum == roomNum);
            b.roomNum = retrieveRoomStatusReportByRoomNum.roomNum;
            b.roomType = retrieveRoomStatusReportByRoomNum.roomType;
            b.floorLevel = retrieveRoomStatusReportByRoomNum.floorLevel;
            b.bedType = retrieveRoomStatusReportByRoomNum.bedType;
            b.smokingOrNot = retrieveRoomStatusReportByRoomNum.smokingOrNot;
            b.maxOccupancy = retrieveRoomStatusReportByRoomNum.maxOccupancy;
            b.roomStatus = retrieveRoomStatusReportByRoomNum.roomStatus;
            b.roomRates = retrieveRoomStatusReportByRoomNum.roomRates;
            return b;

        }
    }
}
